<?php
if (!empty($user)):
?>

<?php
	echo FHtml::beginForm(array('save'));
//	if($user->Id <= 0) FHtml::setScenario('register'); else FHtml::setScenario('editAccount');
	echo FHtml::activeHiddenField($user,'Id');
	echo FHtml::activeHiddenField($user, 'Status');
?>

<h3>Edit user</h3>
<div class="Input">
    <label for="User_Username">Username *: </label>
    <?php echo FHtml::activeTextField($user,'Username'); ?>
</div>
<div class="Input">
    <label for="User_Password">Password <?php echo $requiredField = ($user->Id > 0) ? '' : '*' ?>: </label>
    <?php echo FHtml::activePasswordField($user,'Password'); ?>
</div>
<div class="Input">
    <label for="User_rePassword">Password (confirm) <?php echo $requiredField = ($user->Id > 0) ? '' : '*' ?>: </label>
    <?php echo FHtml::activePasswordField($user,'rePassword'); ?>
</div>
<div class="Input">
    <label for="User_FirstName">First Name *: </label>
    <?php echo FHtml::activeTextField($user,'FirstName'); ?>
</div>
<div class="Input">
    <label for="User_LastName">Last Name *: </label>
    <?php echo FHtml::activeTextField($user,'LastName'); ?>
</div>
<div class="Input">
    <label for="User_Email">Email address *: </label>
    <?php echo FHtml::activeTextField($user,'Email'); ?>
</div>

<?php if($user->Id > 0) : ?>
	<div class="Input">
	    <label for="User_Status">Status *: </label>
	    <?php echo FHtml::activeDropDownList($user, 'Status', $user->StatusCollection); ?>
	</div>
<?php endif; ?>

<div class="Action">
    <?php echo FHtml::submitButton('Save'); ?>
    <?php if ($user->Id > 0) echo FHtml::link('User roles | ', array('/Core/auth/assignment/user', 'id' => $user->Id)); ?>
    <?php echo FHtml::link('Cancel', array('/Core/user/list')); ?>
</div>
<?php
echo FHtml::endForm();
?>

<?php
$cs = Yii::app()->ClientScript;
$cs->registerScriptFile(Yii::app()->theme->BaseUrl.'/scripts/common.js', CClientScript::POS_BEGIN);
endif; //!empty($user)
?>
